package com.hanrui.android.widget.bottomnavigationbar;

import android.content.Context;
import android.util.AttributeSet;

import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.hanrui.android.R;

/**
 * Created by Administrator on 2018/3/9.
 */

public class BottomMainBar extends BottomNavigationBar {

    public BottomMainBar(Context context) {
        this(context, null);
    }

    public BottomMainBar(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public BottomMainBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    BottomNavigationItem messageItem;
    BottomNavigationItem workItem;
    BottomNavigationItem mobileItem;
    BottomNavigationItem personalItem;

    private void init(){
        messageItem = new BottomNavigationItem(R.mipmap.bottom_message_select,"消息")
                        .setInactiveIconResource(R.mipmap.bottom_message_unselect)
                        .setActiveColorResource(R.color.c_2795ff)
                        .setInActiveColorResource(R.color.c_666666);

        workItem = new BottomNavigationItem(R.mipmap.bottom_work_select,"工作")
                    .setInactiveIconResource(R.mipmap.bottom_work_unselect)
                    .setActiveColorResource(R.color.c_2795ff)
                    .setInActiveColorResource(R.color.c_666666);

        mobileItem = new BottomNavigationItem(R.mipmap.bottom_address_select,"通讯录")
                .setInactiveIconResource(R.mipmap.bottom_address_unselect)
                .setActiveColorResource(R.color.c_2795ff)
                .setInActiveColorResource(R.color.c_666666);

        personalItem = new BottomNavigationItem(R.mipmap.bottom_mine_select,"我的")
                .setInactiveIconResource(R.mipmap.bottom_mine_unselect)
                .setActiveColorResource(R.color.c_2795ff)
                .setInActiveColorResource(R.color.c_666666);

        //设置底部导航模式及样式
        setMode(BottomNavigationBar.MODE_FIXED);
        setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
        setBarBackgroundColor(R.color.white);
        addItem(messageItem).addItem(workItem).addItem(mobileItem).addItem(personalItem).setFirstSelectedPosition(0).initialise();
    }

}
